/*
package com.mediacloud.app.newsmodule.fragment.comment;


import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.mediacloud.app.assembly.util.Utility;
import com.mediacloud.app.assembly.views.XRefreashListView;
import com.mediacloud.app.assembly.views.XRefreashListView.IXListViewListener;
import com.mediacloud.app.model.fragment.BaseFragment;
import com.mediacloud.app.model.interfaces.DataInvokeCallBack;
import com.mediacloud.app.model.news.ArticleItem;
import com.mediacloud.app.user.model.UserInfo;
import com.mediacloud.app.newsmodule.R;
import com.mediacloud.app.newsmodule.activity.CommentActivity;
import com.mediacloud.app.newsmodule.adaptor.comment.CommentItemHolder;
import com.mediacloud.app.newsmodule.adaptor.comment.NewsCommentItemAdaptor;
import com.mediacloud.app.newsmodule.model.CommentListDataReciver;
import com.mediacloud.app.newsmodule.model.NewsCommentItem;
import com.mediacloud.app.newsmodule.utils.CommentListDataInvoker;
import com.mediacloud.app.newsmodule.utils.CommentPopFactroy;
import com.mediacloud.app.newsmodule.view.CommentInputView;
import com.mediacloud.app.newsmodule.view.CommentInputView.SubmitCommentListener;

import org.json.JSONObject;

public class NewsCommentFragment extends BaseFragment implements IXListViewListener {

    protected View mCommentListView;
    protected View mLoadingView;
    protected TextView letmeSay, emptyTipsText;
    private NewsCommentItemAdaptor newsCommentItemAdaptor;
    protected CommentInputView commentInputView;
    View mEmptyContent;
    protected CommentListDataInvoker commentListInvoker;
    protected View lemesaylinly;
    protected ImageView letmeSaybnt;
    public ArticleItem articleItem;
    protected int page = 1;
    CommentListCallBack commentListCallBack;
    ShareViewHolder mShareViewHolder;

    String shareUrl = null;

    @Override
    public int getLayoutResID() {
        return R.layout.aappfactory_fragment_newscomment;
    }


    @Override
    public void onResume()
    {
        super.onResume();
    }

    @Override
    public void initView() {
        boolean tag = getFragmentArguments().getBoolean("tag", false);
        articleItem = getFragmentArguments().getParcelable("data");
        shareUrl = articleItem.getUrl();
        newsCommentItemAdaptor = new NewsCommentItemAdaptor(getActivity());
        newsCommentItemAdaptor.mShareUrl = shareUrl;
        newsCommentItemAdaptor.newsTitle = articleItem.getTitle();
        letmeSaybnt = Utility.findViewById(mRootView, R.id.letmeSaybtn);
        letmeSaybnt.setVisibility(tag ? View.GONE : View.VISIBLE);
        letmeSaybnt.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                gotoCommentActivity();
            }
        });
        mShareViewHolder = new ShareViewHolder(mRootView);
        newsCommentItemAdaptor.setShareViewHolder(mShareViewHolder);
        emptyTipsText = Utility.findViewById(mRootView, R.id.emptyTipsText);
        mEmptyContent = Utility.findViewById(mRootView, R.id.mEmptyContent);
        mCommentListView = Utility.findViewById(mRootView, R.id.mCommentListView);
        Utility.invokeMethod(mCommentListView,"setAdapter",new Object[]{newsCommentItemAdaptor},new Class[]{ListAdapter.class});
//        mCommentListView.setAdapter(newsCommentItemAdaptor);

        commentInputView = Utility.findViewById(mRootView, R.id.commentInputView);
        mLoadingView = Utility.findViewById(mRootView, R.id.mLoadingView);
        letmeSay = Utility.findViewById(mRootView, R.id.letmeSay);
        lemesaylinly = Utility.findViewById(mRootView, R.id.lemesaylinly);
        if(mCommentListView instanceof XRefreashListView)
        {
            XRefreashListView mCommentListView= (XRefreashListView) this.mCommentListView;
            mCommentListView.setPullRefreshEnable(true);
            mCommentListView.setPullLoadEnable(true);
            mCommentListView.setXListViewListener(this);
        }
        mCommentListView.setOnTouchListener(new OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                hideInputComment();
                return false;
            }
        });
        mEmptyContent.setOnTouchListener(new OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                hideInputComment();
                return false;
            }
        });

        lemesaylinly.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.w(TAG, "let me say");
                lemesaylinly.setVisibility(View.GONE);
                commentInputView.isReply = false;
                commentInputView.setVisibility(View.VISIBLE);
                commentInputView.show();

            }
        });
        commentInputView.cancelComment.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                hideInputComment();
            }
        });
        mEmptyContent.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                onRefresh();
            }
        });
        commentInputView.articleItem = articleItem;
        CommentPopFactroy.articleItem = articleItem;
        commentInputView.commentListener = new SubmitCommentListener() {

            @Override
            public void success() {
                hideInputComment();
                onRefresh();
            }

            @Override
            public void failed() {

            }
        };
        newsCommentItemAdaptor.setOnReplyListener(new CommentItemHolder.OnReplyListener() {
            @Override
            public void onReplys(NewsCommentItem commentItem) {
                lemesaylinly.setVisibility(View.GONE);
                commentInputView.isReply = true;
                commentInputView.setReplyData(commentItem);
                commentInputView.setVisibility(View.VISIBLE);
                commentInputView.show();
            }

            @Override
            public void onComment(JSONObject obj) {
                lemesaylinly.setVisibility(View.GONE);
                commentInputView.isReply = true;
                commentInputView.setReplyJsData(obj);
                commentInputView.setVisibility(View.VISIBLE);
                commentInputView.show();
            }
        });
    }


    @Override
    protected void initOther() {
        commentListCallBack = new CommentListCallBack();
        commentListInvoker = new CommentListDataInvoker(commentListCallBack);
        onRefresh();
    }

    protected void hideInputComment() {
        lemesaylinly.setVisibility(View.VISIBLE);
        letmeSay.setVisibility(View.VISIBLE);
        commentInputView.setVisibility(View.GONE);
        boolean tag = getFragmentArguments().getBoolean("tag", false);
        letmeSaybnt.setVisibility(tag ? View.GONE : View.VISIBLE);
        commentInputView.hide();

    }

    protected void getNewsComment() {
        if(mCommentListView instanceof XRefreashListView)
        {
            XRefreashListView mCommentListView = (XRefreashListView) this.mCommentListView;
            mCommentListView.setRefreshTime(null);
        }
        if (articleItem != null) {
            UserInfo userInfo = UserInfo.getUserInfo(getContext());
            commentListInvoker.getCommentList(String.valueOf(articleItem.getId()), page, userInfo.getUserid());
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (commentListInvoker != null)
            commentListInvoker.destory();
        commentInputView.destory();
        commentInputView = null;
    }

    protected class CommentListCallBack implements DataInvokeCallBack<CommentListDataReciver> {

        @Override
        public void success(CommentListDataReciver data) {
            if(mCommentListView instanceof XRefreashListView)
            {
                XRefreashListView mCommentListView = (XRefreashListView) NewsCommentFragment.this.mCommentListView;
                mCommentListView.stopLoadMore();
                mCommentListView.stopRefresh();
                mCommentListView.setPullRefreshEnable(true);
                mCommentListView.setPullLoadEnable(data.more);
            }
            if (data.state&&data.commentList!=null&&data.commentList.size()>0)
            {
                if (page == 1)
                {
                    if (newsCommentItemAdaptor.getListContentData() != null) {
                        newsCommentItemAdaptor.setListContentData(data.commentList);
                    }
                    newsCommentItemAdaptor.setListContentData(data.commentList);
                } else {
                    newsCommentItemAdaptor.getListContentData().addAll(data.commentList);
                }
                newsCommentItemAdaptor.notifyDataSetChanged();
//                if (data.page == data.pages) {
//                    mCommentListView.setPullLoadEnable(false);
//                } else {
//                    mCommentListView.setPullLoadEnable(true);
//                }
                mLoadingView.setVisibility(View.GONE);


                if (newsCommentItemAdaptor.getCount() > 0)
                    mEmptyContent.setVisibility(View.GONE);
                else {
                    mEmptyContent.setVisibility(View.VISIBLE);
                    emptyTipsText.setText(R.string.empty_comment);
                    if(mCommentListView instanceof XRefreashListView)
                    {
                        XRefreashListView mCommentListView = (XRefreashListView) NewsCommentFragment.this.mCommentListView;
                        mCommentListView.setPullLoadEnable(false);
                    }
                }
            }
            else if(newsCommentItemAdaptor.getListContentData()==null||newsCommentItemAdaptor.getListContentData().size()==0)
            {
                fault(null);
            }
        }

        @Override
        public void fault(Object data) {
            page--;
            mEmptyContent.setVisibility(View.VISIBLE);
            mLoadingView.setVisibility(View.GONE);
            emptyTipsText.setText(R.string.empty_comment);
            if(mCommentListView instanceof XRefreashListView)
            {
                XRefreashListView mCommentListView = (XRefreashListView) NewsCommentFragment.this.mCommentListView;
                mCommentListView.stopLoadMore();
                mCommentListView.stopRefresh();
                mCommentListView.setPullLoadEnable(false);
                mCommentListView.setPullRefreshEnable(true);
            }
        }

    }

    @Override
    public void onRefresh() {
        page = 1;
        if(mCommentListView instanceof XRefreashListView)
        {
            XRefreashListView mCommentListView = (XRefreashListView) NewsCommentFragment.this.mCommentListView;
            mCommentListView.setPullLoadEnable(false);
        }
        emptyTipsText.setText("");
        getNewsComment();
    }

    @Override
    public void onLoadMore() {
        page++;
        if(mCommentListView instanceof XRefreashListView)
        {
            XRefreashListView mCommentListView = (XRefreashListView) NewsCommentFragment.this.mCommentListView;
            mCommentListView.setPullRefreshEnable(false);
        }
        emptyTipsText.setText("");
        getNewsComment();
    }

    public void gotoCommentActivity() {
        Intent intent = new Intent();
        intent.putExtra("data", articleItem);
        intent.setClass(this.getActivity(), CommentActivity.class);
        startActivity(intent);
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        outState.putParcelable("data", articleItem);
        boolean tag = getFragmentArguments().getBoolean("tag", false);
        outState.putBoolean("tag", tag);
        super.onSaveInstanceState(outState);
    }
}
*/